package com.homegoods.videomodule.presenter;

import com.homegoods.classify.model.Constant;
import com.homegoods.videomodule.model.AnchorCaseModel;
import com.kedll.library.mvp.AbstractRefreshPresenter;
import com.kedll.library.mvp.RefreshingView;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class AnchorHomePresenter extends AbstractRefreshPresenter {
    public AnchorHomePresenter(RefreshingView view) {
        super(view);
    }

    @Override
    protected void fetchData(boolean isLoadMore) {

        addSubscription(Observable.range(0, 12)
                .map(integer -> {
                    AnchorCaseModel model = new AnchorCaseModel();
                    model.setCount(String.valueOf(2 * 1024 * 1024));
                    model.setDate("09月11日 20：30");
                    model.setId(String.valueOf(integer * page + PER_PAGE_COUNT));
                    model.setImgUrl(Constant.TEST_AD_URL + Constant.random.nextInt());
                    model.setTitle("2018秋季就应该这么搭");
                    return model;
                })
                .toList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(anchorCaseModels -> parserData(isLoadMore, anchorCaseModels)));

    }
}